package com.snake.springboot.custom.service.port.adapter.listener;


import com.snake.springboot.custom.api.response.bill.BillRsp;
import com.snake.springboot.custom.api.service.bill.BillService;
import com.snake.springboot.custom.service.port.adapter.event.BillPayedAddEvent;
import com.snake.springboot.custom.service.port.adapter.event.BillPlaceOrderEvt;
import com.snake.springboot.custom.service.port.adapter.event.BillRetEdEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

/**
 * <p>账单监听事件
 * 类{@code BillListener} </br>
 * 创建时间2025/4/6 9:39
 * @author yangxt
 * @see
 */
@Component
public class BillListener {
    @Autowired
    private BillService billService;


    @EventListener
    public void billPlace(BillPlaceOrderEvt event){
        BillRsp billRsp = billService.placeOrder(event.getData());
        event.setResult(billRsp);
    }


    @EventListener
    public void billPayedAdd(BillPayedAddEvent event){
        billService.billPayedAdd(event.getData());
    }

    @EventListener
    public void billRetEd(BillRetEdEvent event){
        billService.billRetEd(event.getData());
    }
}
